package com.caipiao.lottery.task;

import jodd.datetime.JDateTime;

public class TaskStatus
{
	public String Name = "";
	public String ThrdName = "";
	public int Interval = 0;
	public long IntervalTimes = 0;
	
	public int CacheSize = -1;
	
	public long SucessCount = -1;
	public long FailedCount = -1;
	
	public JDateTime lastExeTime = new JDateTime();
	public JDateTime lastSuccTime = new JDateTime();
	
	public void AddInterval()
	{
		IntervalTimes++;
		lastExeTime = new JDateTime();
	}
	
	public void AddSuccess()
	{
		SucessCount++;
		lastSuccTime = new JDateTime();
	}
	
	public void AddFailed()
	{
		FailedCount++;
	}
	
	public String GetStatusDesc()
	{
		StringBuffer str_buff = new StringBuffer();

		str_buff.append("name:");
		str_buff.append(Name);
		str_buff.append(" thrd:");
		str_buff.append(ThrdName);
		
		str_buff.append(" interval:");
		str_buff.append(Interval);
		
		str_buff.append(" intervalTimes:");
		str_buff.append(IntervalTimes);
		
		if (this.CacheSize > -1)
		{
			str_buff.append(" cacheSize:");
			str_buff.append(CacheSize);
		}
		
		if (SucessCount > -1)
		{
			str_buff.append(" sucess:");
			str_buff.append(SucessCount);
		}
		
		if (FailedCount > -1)
		{
			str_buff.append(" failed:");
			str_buff.append(FailedCount);
		}
		
		str_buff.append(" lastExe:");
		str_buff.append(this.lastExeTime.toString("MM-DD hh:mm:ss"));
		
		str_buff.append(" lastSucc:");
		str_buff.append(this.lastExeTime.toString("MM-DD hh:mm:ss"));

		return str_buff.toString();
	}
}
